<%= form_for([:admin,@article],html:{class:'form-horizontal'}) do |f| %>
  <% if @article.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@article.errors.count, "error") %> prohibited this article from being saved:</h2>

      <ul>
      <% @article.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
      </ul>
    </div>
  <% end %>
    <h3><%= params[:action] == 'edit' ? '编辑文章信息' : '新建文章信息' %></h3>
    <hr>
    <div class="form-group">
      <label class="control-label col-md-2">文章名称</label>
      <div class="col-md-10">
        <%= f.text_field :title ,class:'form-control',placeholder:'请输入文章名称' %>
      </div>
    </div>
    <div class="form-group">
      <label class="control-label col-md-2">文章分类</label>

      <div class="col-md-10">
        <% Category.where(is_deleted: 0).each do |category| %>
            <label class="checkbox-inline">
              <input <%= "checked='checked'" if @article.include_category?(category) %> type="checkbox" name="article[category_ids][]" value="<%= category.id %>"> <%= category.name %>
            </label>
        <% end %>
      </div>
    </div>
    <div class="form-group">
      <label class="control-label col-md-2">标签</label>
      <div class="col-md-10">
        <% Tag.where(is_deleted: 0).each do |tag| %>
            <label class="checkbox-inline">
              <input <%= "checked='checked'" if @article.include_tag?(tag) %> type="checkbox" name="article[tag_ids][]"  value="<%= tag.id %>"> <%= tag.name %>
            </label>
        <% end %>
      </div>
    </div>
    <div class="form-group">
      <div class="col-md-12">
        <%= f.text_area :content %>
      </div>
    </div>
    <div class="form-group">
        <input type="submit" class=" col-md-offset-4 btn btn-primary btn-lg col-md-4" value="提交" />
    </div>
<% end %>
